package demo1;

import java.util.Comparator;

public class AgeComparator implements Comparator {

    @Override
    public int compare(Object obj1, Object obj2) {
        if (obj1 instanceof StudentComparator && obj2 instanceof StudentComparator) {
            StudentComparator s1 = (StudentComparator) obj1;
            StudentComparator s2 = (StudentComparator) obj2;

            return s1.age - s2.age;
        }
        throw new RuntimeException("类型不匹配");
    }
}
